'use strict';

const Service = require('egg').Service;

class SettingService extends Service {


  // 获取列表
  async get() {
    const { app } = this;
    try {
      const res = await app.model.Setting.findAll({
        attributes: [
          'id',
          'name',
          'keywords',
          'description',
          'url',
          'logo',
          'stutas',
        ],
      });
      return res[0];
    } catch (error) {
      console.error(error);
      return null;
    }
  }

  // 修改
  async updated(id, setting) {
    const { app } = this;
    return await app.model.Setting.update(setting, { where: { id } });
  }

}

module.exports = SettingService;
